package pt.isel.lercm.projectmanager.spring.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pt.isel.lercm.projectmanager.spring.dao.RoleDAO;
import pt.isel.lercm.projectmanager.spring.model.Role;

@Service("RoleService")
@Transactional(readOnly = true)
public class RoleService implements IRoleService{
	
	@Autowired
	RoleDAO roleDao;

	public RoleDAO getRoleDao() {
		return roleDao;
	}

	public void setRoleDao(RoleDAO roleDao) {
		this.roleDao = roleDao;
	}
	
	@Transactional(readOnly = false)
	@Override
	public void add(Role Role){
		getRoleDao().addObject(Role);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void update(Role Role){
		getRoleDao().updateObject(Role);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void delete(Role Role){
		getRoleDao().deleteObject(Role);
	}
	
	@Override
	public Role getById(int id){
		return getRoleDao().getByid(id);
	}
	
	@Override
	public List<Role> getAll(){
		return getRoleDao().getAll();
	}
}
